using Game.Component.Character;
using Game.Main.Model;

namespace Game.Component
{
	public class ToothBrushItem : BaseItem
	{
		private CharacterItem targetItem;

		private ItemComponentTrigger targetTrigger;

		public override void Init(ItemArchiveData data)
		{
			base.Init(data);
		}

		protected override void PlayDragEffect(float z = -0.0004f)
		{
		}

		protected override void PlayDragSound()
		{
		}

		protected override void OnItemCompTriggerEnter(ColliderData collData)
		{
			base.OnItemCompTriggerEnter(collData);
			if (collData.trigger.type == ItemComponentTrigger.Type.Mouth && typeof(CharacterItem).IsAssignableFrom(collData.trigger.owner.GetType()))
			{
				targetTrigger = collData.trigger;
				targetItem = (CharacterItem)collData.trigger.owner;
				targetItem.SetMouthState(Face.MouthState.Open);
				base.PlayDragEffect();
				base.PlayDragSound();
			}
		}

		protected override void OnItemCompTriggerExit(ColliderData collData)
		{
			base.OnItemCompTriggerExit(collData);
			if (collData.trigger == targetTrigger)
			{
				ResetTarget();
				StopDragSound();
				StopDragEffect();
			}
		}

		public override void TouchUp(TouchEventData touchEventData)
		{
			base.TouchUp(touchEventData);
			ResetTarget();
		}

		private void ResetTarget()
		{
			if (targetItem != null)
			{
				targetItem.SetMouthState(Face.MouthState.Normal);
				targetTrigger = null;
				targetItem = null;
			}
		}
	}
}
